<%-- 
    Document   : CarBooking
    Created on : Nov 1, 2011, 11:24:48 PM
    Author     : Mr-aUgust
--%>

<%@ page session="true" import="java.util.Collection, DAL.*" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="/WEB-INF/taglib139.tld" prefix="pg" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>East2West Tours and Travels</title>
        <style type="text/css">
            #Table
            {
            border:1px solid green;
            }
            th
            {
            border:1px solid green;
            background-color:green;
            color:white;
            }
            .td
            {
            border:1px solid green;
            }
            .font
            {
            font-family:"Times New Roman", Times, serif;
            font-size:x-large;
            font-weight:bold;
            width:200px;
            margin-left:auto;
            margin-right:auto;
            color:#0707e7;
            }
            .a
            {
                color:#0707e7;
            }
        </style>
    </head>
    <body>
        <%
        session.removeAttribute("status");
        session.removeAttribute("statusH");
        String key="";
        CarBookBean cbb=new CarBookBean();
        if(request.getParameter("key")!=null) {
            key=request.getParameter("key");
            String type=request.getParameter("type");
            if(type.equals("Username"))
                {
                   if(key=="")
                   {
                        Collection coll=cbb.SelectCarBook();
                         request.setAttribute("carb",coll);
                    }
                    if(key.length()>0)
                        {
                        Collection coll=cbb.SearchCarBookUserName(key);
                        request.setAttribute("carb",coll);
                        }
                }
            if(type.equals("Carid"))
                {
                     if(key=="")
                     {
                        Collection coll=cbb.SelectCarBook();
                         request.setAttribute("carb",coll);
                     }
                    if(key.length()>0)
                        {
                        Collection coll=cbb.SearchCarBookCarid(key);
                        request.setAttribute("carb",coll);
                        }
                }

          if(type.equals("Bookid"))
               {
                    if(key=="")
                     {
                        Collection coll=cbb.SelectCarBook();
                         request.setAttribute("carb",coll);
                     }
                    if(key.length()>0)
                     {
                        Collection coll=cbb.SearchCarBookID(key);
                        request.setAttribute("carb",coll);
                    }
              }
           
        } else {
            Collection coll=cbb.SelectCarBook();
            request.setAttribute("carb",coll);
        }
        %>
        
        <div class="font">List Cars Rental</div>  
        <table width="100%">
            <tr>
                <td>
                    <form action="management.jsp?page=CarBooking" method="post">
                        <b>Input Username Or ID Car, Booking:</b><input type="text" name="key" size="40" />
                        <input type="radio" name="type" value="Username" checked="true"/>User Name
                        <input type="radio" name="type" value="Carid"/>Car ID
                        <input type="radio" name="type" value="Bookid"/>Book ID
                        <input type="submit" value="Search"/>
                    </form>
                </td>
            </tr>  
        </table>
        <table width="100%" id="Table">         
            <tr>
                <th>ID</th>
                <th>UserName</th>
                <th>CarID</th>
                <th>Driver</th>
                <th>Pick Up Date</th>
                <th>Drop Off Date</th>
                <th>Time</th>
                <th>Total Money</th>
                <th>DateBook</th>
                <th>Receive Car</th>
                <%--<th>Delete</th>--%>
            </tr>
            <pg:paging pageSize="10" url="management.jsp?page=CarBooking"  >
                <c:forEach items="${carb}" var="cr">
                    <pg:item>
                        <tr>
                            <td class="td">${cr.bookingID}</td>
                            <td class="td" width="60px">${cr.userName}</td>
                            <td class="td">${cr.carID}</td>
                            <td class="td">${cr.driver}</td>
                            <td class="td">${cr.pickUpDate}</td>
                            <td class="td">${cr.dropOffDate}</td>
                            <td class="td">${cr.time}</td>
                            <td class="td"><f:formatNumber value="${cr.totalMoney}" pattern="$#,###" /></td>
                            <td class="td">${cr.dateBooking}</td>   
                            <td class="td" width="70px">
                              <form action="../ControllerUpdateStatus" method="post">
                                <input type="hidden" name="bookingID" value="${cr.bookingID}" />
                                <input type="hidden" name="carID" value="${cr.carID}" />
                                <input type="submit" name="nhanxe" value="Receive"/>
                              </form>
                            </td>                          
                            <%--<td class="td" width="60px">
                                <form action="../ControllerCarBook" method="post" name="delete">
                                    <input type="hidden" name="bookingID" value="${cr.bookingID}" />
                                    <input type="submit" name="delete" value="Delete" OnClick="return confirm('Are you sure you want delete record this?');"/>
                                </form>
                            </td>--%>
                        </tr>
                    </pg:item>       
                </c:forEach>
                <pg:index>
                    <pg:page><%=thisPage%></pg:page>
                </pg:index>
            </pg:paging>
        </table>
        <br>
        <a class="a" href="management.jsp?page=ListRentalCar">List All Of Cars Rental</a>
    </body>
</html>

